home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CASample / CAS_Error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  2.0 KB  |  118 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.  
  4.     File:        CAS_Error.c
  5.  
  6.     Contains:    CASample error reporting routines
  7.  
  8.     Written by:    Rick Badertscher
  9.  
  10.     Copyright © 1988-1995 Apple Computer, All rights reserved.
  11.  
  12.     Change History (most recent first):
  13.  
  14.          <0>     11/17/95    RB        Created
  15. */
  16.  
  17. #ifdef USE_CALIB
  18. #include "CALib.h"
  19. #endif
  20.  
  21. #include "CAS_Error.h"
  22. #include "CAS_App.h"
  23. #include "CAS_Globals.h"
  24. #include "CAS_StringTools.h"
  25.  
  26. //----------------------------------------------------------------------
  27. //    Error_Dialog
  28.  
  29. void Error_ReportOperationError(OSErr    theErr)
  30. {
  31. Str32        errorString;
  32. Str32        errorNumString;
  33. WindowPtr    frontWindow;
  34. short        stringIndex;
  35.  
  36.     
  37.     frontWindow = App_GetFrontDocWindow();
  38.     
  39.     // Get the modal focus
  40.     
  41. #ifdef USE_CALIB
  42.     if (gCALibExists)
  43.         if (!CARequestModalFocus(frontWindow))
  44.             return;
  45. #endif
  46.  
  47.     if ((theErr >= kCASErrBase) && (theErr <= kCASErrLast))
  48.     {
  49.         // Get the CASample error string
  50.         stringIndex = theErr - kCAErrBase;
  51.         GetIndString( errorString, kErrorStringRsrc, theErr );
  52.         ParamText( errorString, nil, nil, nil );
  53.  
  54.     }
  55.     else
  56.     {
  57.         // Not a CASample error, so show the error number
  58.         sCopyStr ("\pUnknown", errorString);
  59.         NumToString (theErr, errorNumString);
  60.         ParamText( errorString, errorNumString, nil, nil );
  61.  
  62.     }
  63.     
  64.  
  65.     // Display the error dialog
  66.  
  67.     Dialog_CenterALRTonFrontWindow( kOperationErrorDialog );
  68.     StopAlert( kOperationErrorDialog, nil );
  69.  
  70.     // Relinquish the modal focus
  71.     
  72. #ifdef USE_CALIB
  73.     if (gCALibExists)
  74.         CARelinquishModalFocus(frontWindow);
  75. #endif
  76. }
  77.  
  78.  
  79.  
  80.  
  81. void    Error_ShowMessage(            short msgIndex)
  82. {
  83. Str32        errorString;
  84. WindowPtr    frontWindow;
  85.  
  86.     
  87.     frontWindow = App_GetFrontDocWindow();
  88.     
  89.     // Get the modal focus
  90.     
  91. #ifdef USE_CALIB
  92.     if (gCALibExists)
  93.         if (!CARequestModalFocus(frontWindow))
  94.             return;
  95. #endif
  96.  
  97.     // Get the CASample error string
  98.     GetIndString( errorString, kMessageStringRsrc, msgIndex );
  99.  
  100.     ParamText( errorString, nil, nil, nil );
  101.  
  102.     // Display the error dialog
  103.  
  104.     Dialog_CenterALRTonFrontWindow( kMessageDialog );
  105.     StopAlert( kMessageDialog, nil );
  106.  
  107.     // Relinquish the modal focus
  108.     
  109. #ifdef USE_CALIB
  110.     if (gCALibExists)
  111.         CARelinquishModalFocus(frontWindow);
  112. #endif
  113.  
  114.  
  115. }
  116.  
  117.  
  118.